package com.yisu.es.resp;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.List;


/**
 * @author xuyisu
 */
@Data
public class ElasticsearchResponse<T> {
    @JsonProperty("took")
    private int took;
    @JsonProperty("timed_out")
    private boolean timedOut;
    @JsonProperty("_shards")
    private Shards shards;
    @JsonProperty("hits")
    private Hits<T> hits;


    @Data
    public static class Shards {
        @JsonProperty("total")
        private int total;
        @JsonProperty("successful")
        private int successful;
        @JsonProperty("skipped")
        private int skipped;
        @JsonProperty("failed")
        private int failed;

    }

    @Data
    public static class Hits<T> {
        @JsonProperty("total")
        private Total total;

        @JsonProperty("max_score")
        private double maxScore;

        @JsonProperty("hits")
        private List<Hit<T>> hits;


        @Data
        public static class Total {
            @JsonProperty("value")
            private int value;
            @JsonProperty("relation")
            private String relation;
        }

        @Data
        public static class Hit<T> {
            @JsonProperty("_index")
            private String index;
            @JsonProperty("_type")
            private String type;
            @JsonProperty("_id")
            private String id;
            @JsonProperty("_score")
            private double score;
            @JsonProperty("_source")
            private T source;

        }
    }
}

